package demo.practice.backtrack;

public class P494 {


    int times = 0;

    public int findTargetSumWays(int[] nums, int target) {
        findTargetSumWays(nums, target, 0);
        return times;
    }


    public void findTargetSumWays(int[] nums, int target, int index) {

        if(index>=nums.length)
            return;

        int cur = nums[index];
        if (index == nums.length - 1 && cur == target) {
            times++;
        }

        if (index == nums.length - 1 && cur == -target) {
            times++;
        }

        findTargetSumWays(nums, target+cur, index+1);
        findTargetSumWays(nums, target-cur, index+1);
    }
}
